package com.xian.producer;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.Properties;

/**
 * kafka生产者测试
 */
public class MyProducer {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "r71:9092,r72:9092,r73:9092");
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        KafkaProducer producer = new KafkaProducer(props);


        //producer.send(new ProducerRecord("jemson-topic", "testProducer"));
        for (int i=1; i<=100; i++) {
            producer.send(new ProducerRecord("jemson-topic", i+"", "Jemson-景甜-"+i));
        }



        producer.close();
    }
}
